package com.orange.wwwapi.controller.shop;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.orange.core.pojo.PageReqDto;
import com.orange.core.pojo.R;
import com.orange.core.pojo.entity.shop.vo.ShopVO;
import com.orange.core.pojo.enums.ShopStatus;
import com.orange.core.pojo.req.shop.ShopPageReq;
import com.orange.core.service.shop.ShopService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

/**
 * <p>ClassName:ShopController</p>
 * <p>Description: 品牌商铺Controller</p>
 * <p>Author: lwm</p>
 * <p>Date: 2025/6/1 21:00</p>
 */
@RequiredArgsConstructor
@RestController
@RequestMapping("/shop")
public class ShopController {

    private final ShopService shopService;

    /**
     * 品牌商铺分页查询
     * @param pageReqDto
     * @return
     */
    @PostMapping("/page")
    public R<Page<ShopVO>> page(@RequestBody PageReqDto<ShopPageReq> pageReqDto){
        ShopPageReq condition = pageReqDto.getCondition();
        condition.setStatus(ShopStatus.NORMAL.getCode());
        pageReqDto.setCondition(condition);
        Page<ShopVO> page = shopService.page(pageReqDto);
        return R.ok(page);
    }

    /**
     * 品牌商铺详情
     * @param id
     * @return
     */
    @GetMapping("/info/{id}")
    public R<ShopVO> info(@PathVariable("id") int id){
        return R.ok(shopService.info(id));
    }

}
